/*************************************************************************
    > File Name: hwled.c
    > Author: ma6174
    > Mail: ma6174@163.com 
    > Created Time: 2025年02月08日 星期六 09时18分10秒
 ************************************************************************/

#include "hwled.h"

#define LED_ON	0x1101
#define LED_OFF	0x1102

static int fd;

void led_init(void){
	fd = open("/dev/myled", O_RDWR);
	
	if(fd < 0){
	
		printf("%s:led init error, %s # %s \n", __func__, __DATE__, __TIME__);
	
	}

};

void led_on(int index){
	ioctl(fd, LED_ON, &index);
};

void led_off(int index){
	ioctl(fd, LED_OFF, &index);
};

void led_staut(int index, led_t* pled){

	read(fd, pled, sizeof(led_t));

	//printf("led index = %d, stauts=%d \n", pled->index, pled->stauts);
};

void led_free(void){
	
	if(fd < 0) {
		
		printf("%s:led free error, %s # %s \n", __func__, __DATE__, __TIME__);
		
		return;
	}

	close(fd);
}

